#include"comm.hpp"

int main()
{
    Init init;
    int shmid = CreateShm();
    char* shmaddr = (char*)shmat(shmid, nullptr, 0);

    //int fd = open(FIFO_FILE, O_RDONLY); // 以只读方式打开管道
    if (fd < 0)
    {
        log(Fatal, "error string: %s, error code: %d", strerror(errno), errno);
        exit(FIFO_OPEN_ERR);
    }

    //struct shmid_ds shmds; // 可以获取结构体里面的信息
    while (true)
    {
        /*
        char c;
        ssize_t s = read(fd, &c, 1);
        if (s <= 0)
            break;*/

        cout << "client say@" << shmaddr << endl;
        sleep(1);
    }

    // 收尾工作
    shmdt(shmaddr); // 取消关联
    shmctl(shmid, IPC_RMID, nullptr); // 删除共享内存段

    //close(fd);

    return 0;
}